package registnet.dao;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;

  
  
/**
 * This class was autogenerated by Torque on:
 *
 * [Tue Jun 30 14:38:16 PDT 2009]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Curriculum
 */
public abstract class BaseCurriculum extends BaseObject
{
    /** The Peer class */
    private static final CurriculumPeer peer =
        new CurriculumPeer();

        
    /** The value for the curriculumId field */
    private int curriculumId;
      
    /** The value for the curriculumCode field */
    private String curriculumCode;
      
    /** The value for the curriculumName field */
    private String curriculumName;
                                          
    /** The value for the totalUnits field */
    private int totalUnits = 0;
                                          
    /** The value for the aHCount field */
    private int aHCount = 0;
                                          
    /** The value for the mSTCount field */
    private int mSTCount = 0;
                                          
    /** The value for the sSPCount field */
    private int sSPCount = 0;
                                          
    /** The value for the electiveCount field */
    private int electiveCount =  0;
      
    /** The value for the degreeId field */
    private int degreeId;
  
    
    /**
     * Get the CurriculumId
     *
     * @return int
     */
    public int getCurriculumId()
    {
        return curriculumId;
    }

                                              
    /**
     * Set the value of CurriculumId
     *
     * @param v new value
     */
    public void setCurriculumId(int v) throws TorqueException
    {
    
                  if (this.curriculumId != v)
              {
            this.curriculumId = v;
            setModified(true);
        }
    
          
                                  
        // update associated CurriculumCourse
        if (collCurriculumCourses != null)
        {
            for (int i = 0; i < collCurriculumCourses.size(); i++)
            {
                ((CurriculumCourse) collCurriculumCourses.get(i))
                    .setCurriculumId(v);
            }
        }
                                          
        // update associated Student
        if (collStudents != null)
        {
            for (int i = 0; i < collStudents.size(); i++)
            {
                ((Student) collStudents.get(i))
                    .setCurriculumId(v);
            }
        }
                                          
        // update associated StudentCurriculumTotalUnitsEarned
        if (collStudentCurriculumTotalUnitsEarneds != null)
        {
            for (int i = 0; i < collStudentCurriculumTotalUnitsEarneds.size(); i++)
            {
                ((StudentCurriculumTotalUnitsEarned) collStudentCurriculumTotalUnitsEarneds.get(i))
                    .setCurriculumId(v);
            }
        }
                                          
        // update associated CurriculumClassification
        if (collCurriculumClassifications != null)
        {
            for (int i = 0; i < collCurriculumClassifications.size(); i++)
            {
                ((CurriculumClassification) collCurriculumClassifications.get(i))
                    .setCurriculumId(v);
            }
        }
                      }
  
    /**
     * Get the CurriculumCode
     *
     * @return String
     */
    public String getCurriculumCode()
    {
        return curriculumCode;
    }

                        
    /**
     * Set the value of CurriculumCode
     *
     * @param v new value
     */
    public void setCurriculumCode(String v) 
    {
    
                  if (!ObjectUtils.equals(this.curriculumCode, v))
              {
            this.curriculumCode = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the CurriculumName
     *
     * @return String
     */
    public String getCurriculumName()
    {
        return curriculumName;
    }

                        
    /**
     * Set the value of CurriculumName
     *
     * @param v new value
     */
    public void setCurriculumName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.curriculumName, v))
              {
            this.curriculumName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the TotalUnits
     *
     * @return int
     */
    public int getTotalUnits()
    {
        return totalUnits;
    }

                        
    /**
     * Set the value of TotalUnits
     *
     * @param v new value
     */
    public void setTotalUnits(int v) 
    {
    
                  if (this.totalUnits != v)
              {
            this.totalUnits = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the AHCount
     *
     * @return int
     */
    public int getAHCount()
    {
        return aHCount;
    }

                        
    /**
     * Set the value of AHCount
     *
     * @param v new value
     */
    public void setAHCount(int v) 
    {
    
                  if (this.aHCount != v)
              {
            this.aHCount = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the MSTCount
     *
     * @return int
     */
    public int getMSTCount()
    {
        return mSTCount;
    }

                        
    /**
     * Set the value of MSTCount
     *
     * @param v new value
     */
    public void setMSTCount(int v) 
    {
    
                  if (this.mSTCount != v)
              {
            this.mSTCount = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the SSPCount
     *
     * @return int
     */
    public int getSSPCount()
    {
        return sSPCount;
    }

                        
    /**
     * Set the value of SSPCount
     *
     * @param v new value
     */
    public void setSSPCount(int v) 
    {
    
                  if (this.sSPCount != v)
              {
            this.sSPCount = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the ElectiveCount
     *
     * @return int
     */
    public int getElectiveCount()
    {
        return electiveCount;
    }

                        
    /**
     * Set the value of ElectiveCount
     *
     * @param v new value
     */
    public void setElectiveCount(int v) 
    {
    
                  if (this.electiveCount != v)
              {
            this.electiveCount = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the DegreeId
     *
     * @return int
     */
    public int getDegreeId()
    {
        return degreeId;
    }

                              
    /**
     * Set the value of DegreeId
     *
     * @param v new value
     */
    public void setDegreeId(int v) throws TorqueException
    {
    
                  if (this.degreeId != v)
              {
            this.degreeId = v;
            setModified(true);
        }
    
                          
                if (aDegreeCourse != null && !(aDegreeCourse.getDegreeId() == v))
                {
            aDegreeCourse = null;
        }
      
              }
  
      
    
                  
    
        private DegreeCourse aDegreeCourse;

    /**
     * Declares an association between this object and a DegreeCourse object
     *
     * @param v DegreeCourse
     * @throws TorqueException
     */
    public void setDegreeCourse(DegreeCourse v) throws TorqueException
    {
            if (v == null)
        {
                    setDegreeId(0);
                  }
        else
        {
            setDegreeId(v.getDegreeId());
        }
                aDegreeCourse = v;
    }

                                            
    /**
     * Get the associated DegreeCourse object
     *
     * @return the associated DegreeCourse object
     * @throws TorqueException
     */
    public DegreeCourse getDegreeCourse() throws TorqueException
    {
        if (aDegreeCourse == null && (this.degreeId > 0))
        {
                          aDegreeCourse = DegreeCoursePeer.retrieveByPK(SimpleKey.keyFor(this.degreeId));
              
            /* The following can be used instead of the line above to
               guarantee the related object contains a reference
               to this object, but this level of coupling
               may be undesirable in many circumstances.
               As it can lead to a db query with many results that may
               never be used.
               DegreeCourse obj = DegreeCoursePeer.retrieveByPK(this.degreeId);
               obj.addCurriculums(this);
            */
        }
        return aDegreeCourse;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey.  e.g.
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
           */
    public void setDegreeCourseKey(ObjectKey key) throws TorqueException
    {
      
                        setDegreeId(((NumberKey) key).intValue());
                  }
       
                                
            
    /**
     * Collection to store aggregation of collCurriculumCourses
     */
    protected List collCurriculumCourses;

    /**
     * Temporary storage of collCurriculumCourses to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initCurriculumCourses()
    {
        if (collCurriculumCourses == null)
        {
            collCurriculumCourses = new ArrayList();
        }
    }

    /**
     * Method called to associate a CurriculumCourse object to this object
     * through the CurriculumCourse foreign key attribute
     *
     * @param l CurriculumCourse
     * @throws TorqueException
     */
    public void addCurriculumCourse(CurriculumCourse l) throws TorqueException
    {
        getCurriculumCourses().add(l);
        l.setCurriculum((Curriculum) this);
    }

    /**
     * The criteria used to select the current contents of collCurriculumCourses
     */
    private Criteria lastCurriculumCoursesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCurriculumCourses(new Criteria())
     *
     * @throws TorqueException
     */
    public List getCurriculumCourses() throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            collCurriculumCourses = getCurriculumCourses(new Criteria(10));
        }
        return collCurriculumCourses;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum has previously
     * been saved, it will retrieve related CurriculumCourses from storage.
     * If this Curriculum is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getCurriculumCourses(Criteria criteria) throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            if (isNew())
            {
               collCurriculumCourses = new ArrayList();
            }
            else
            {
                      criteria.add(CurriculumCoursePeer.CURRICULUMID, getCurriculumId() );
                      collCurriculumCourses = CurriculumCoursePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(CurriculumCoursePeer.CURRICULUMID, getCurriculumId());
                      if (!lastCurriculumCoursesCriteria.equals(criteria))
                {
                    collCurriculumCourses = CurriculumCoursePeer.doSelect(criteria);
                }
            }
        }
        lastCurriculumCoursesCriteria = criteria;

        return collCurriculumCourses;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCurriculumCourses(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCurriculumCourses(Connection con) throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            collCurriculumCourses = getCurriculumCourses(new Criteria(10), con);
        }
        return collCurriculumCourses;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum has previously
     * been saved, it will retrieve related CurriculumCourses from storage.
     * If this Curriculum is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCurriculumCourses(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            if (isNew())
            {
               collCurriculumCourses = new ArrayList();
            }
            else
            {
                       criteria.add(CurriculumCoursePeer.CURRICULUMID, getCurriculumId());
                       collCurriculumCourses = CurriculumCoursePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(CurriculumCoursePeer.CURRICULUMID, getCurriculumId());
                       if (!lastCurriculumCoursesCriteria.equals(criteria))
                 {
                     collCurriculumCourses = CurriculumCoursePeer.doSelect(criteria, con);
                 }
             }
         }
         lastCurriculumCoursesCriteria = criteria;

         return collCurriculumCourses;
     }

                        
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum is new, it will return
     * an empty collection; or if this Curriculum has previously
     * been saved, it will retrieve related CurriculumCourses from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Curriculum.
     */
    protected List getCurriculumCoursesJoinCurriculum(Criteria criteria)
        throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            if (isNew())
            {
               collCurriculumCourses = new ArrayList();
            }
            else
            {
                            criteria.add(CurriculumCoursePeer.CURRICULUMID, getCurriculumId());
                            collCurriculumCourses = CurriculumCoursePeer.doSelectJoinCurriculum(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(CurriculumCoursePeer.CURRICULUMID, getCurriculumId());
                        if (!lastCurriculumCoursesCriteria.equals(criteria))
            {
                collCurriculumCourses = CurriculumCoursePeer.doSelectJoinCurriculum(criteria);
            }
        }
        lastCurriculumCoursesCriteria = criteria;

        return collCurriculumCourses;
    }
                  
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum is new, it will return
     * an empty collection; or if this Curriculum has previously
     * been saved, it will retrieve related CurriculumCourses from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Curriculum.
     */
    protected List getCurriculumCoursesJoinCourse(Criteria criteria)
        throws TorqueException
    {
        if (collCurriculumCourses == null)
        {
            if (isNew())
            {
               collCurriculumCourses = new ArrayList();
            }
            else
            {
                            criteria.add(CurriculumCoursePeer.CURRICULUMID, getCurriculumId());
                            collCurriculumCourses = CurriculumCoursePeer.doSelectJoinCourse(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(CurriculumCoursePeer.CURRICULUMID, getCurriculumId());
                        if (!lastCurriculumCoursesCriteria.equals(criteria))
            {
                collCurriculumCourses = CurriculumCoursePeer.doSelectJoinCourse(criteria);
            }
        }
        lastCurriculumCoursesCriteria = criteria;

        return collCurriculumCourses;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collStudents
     */
    protected List collStudents;

    /**
     * Temporary storage of collStudents to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initStudents()
    {
        if (collStudents == null)
        {
            collStudents = new ArrayList();
        }
    }

    /**
     * Method called to associate a Student object to this object
     * through the Student foreign key attribute
     *
     * @param l Student
     * @throws TorqueException
     */
    public void addStudent(Student l) throws TorqueException
    {
        getStudents().add(l);
        l.setCurriculum((Curriculum) this);
    }

    /**
     * The criteria used to select the current contents of collStudents
     */
    private Criteria lastStudentsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getStudents(new Criteria())
     *
     * @throws TorqueException
     */
    public List getStudents() throws TorqueException
    {
        if (collStudents == null)
        {
            collStudents = getStudents(new Criteria(10));
        }
        return collStudents;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum has previously
     * been saved, it will retrieve related Students from storage.
     * If this Curriculum is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getStudents(Criteria criteria) throws TorqueException
    {
        if (collStudents == null)
        {
            if (isNew())
            {
               collStudents = new ArrayList();
            }
            else
            {
                      criteria.add(StudentPeer.CURRICULUMID, getCurriculumId() );
                      collStudents = StudentPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(StudentPeer.CURRICULUMID, getCurriculumId());
                      if (!lastStudentsCriteria.equals(criteria))
                {
                    collStudents = StudentPeer.doSelect(criteria);
                }
            }
        }
        lastStudentsCriteria = criteria;

        return collStudents;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getStudents(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getStudents(Connection con) throws TorqueException
    {
        if (collStudents == null)
        {
            collStudents = getStudents(new Criteria(10), con);
        }
        return collStudents;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum has previously
     * been saved, it will retrieve related Students from storage.
     * If this Curriculum is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getStudents(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collStudents == null)
        {
            if (isNew())
            {
               collStudents = new ArrayList();
            }
            else
            {
                       criteria.add(StudentPeer.CURRICULUMID, getCurriculumId());
                       collStudents = StudentPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(StudentPeer.CURRICULUMID, getCurriculumId());
                       if (!lastStudentsCriteria.equals(criteria))
                 {
                     collStudents = StudentPeer.doSelect(criteria, con);
                 }
             }
         }
         lastStudentsCriteria = criteria;

         return collStudents;
     }

                  
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum is new, it will return
     * an empty collection; or if this Curriculum has previously
     * been saved, it will retrieve related Students from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Curriculum.
     */
    protected List getStudentsJoinCurriculum(Criteria criteria)
        throws TorqueException
    {
        if (collStudents == null)
        {
            if (isNew())
            {
               collStudents = new ArrayList();
            }
            else
            {
                            criteria.add(StudentPeer.CURRICULUMID, getCurriculumId());
                            collStudents = StudentPeer.doSelectJoinCurriculum(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(StudentPeer.CURRICULUMID, getCurriculumId());
                        if (!lastStudentsCriteria.equals(criteria))
            {
                collStudents = StudentPeer.doSelectJoinCurriculum(criteria);
            }
        }
        lastStudentsCriteria = criteria;

        return collStudents;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collStudentCurriculumTotalUnitsEarneds
     */
    protected List collStudentCurriculumTotalUnitsEarneds;

    /**
     * Temporary storage of collStudentCurriculumTotalUnitsEarneds to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initStudentCurriculumTotalUnitsEarneds()
    {
        if (collStudentCurriculumTotalUnitsEarneds == null)
        {
            collStudentCurriculumTotalUnitsEarneds = new ArrayList();
        }
    }

    /**
     * Method called to associate a StudentCurriculumTotalUnitsEarned object to this object
     * through the StudentCurriculumTotalUnitsEarned foreign key attribute
     *
     * @param l StudentCurriculumTotalUnitsEarned
     * @throws TorqueException
     */
    public void addStudentCurriculumTotalUnitsEarned(StudentCurriculumTotalUnitsEarned l) throws TorqueException
    {
        getStudentCurriculumTotalUnitsEarneds().add(l);
        l.setCurriculum((Curriculum) this);
    }

    /**
     * The criteria used to select the current contents of collStudentCurriculumTotalUnitsEarneds
     */
    private Criteria lastStudentCurriculumTotalUnitsEarnedsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getStudentCurriculumTotalUnitsEarneds(new Criteria())
     *
     * @throws TorqueException
     */
    public List getStudentCurriculumTotalUnitsEarneds() throws TorqueException
    {
        if (collStudentCurriculumTotalUnitsEarneds == null)
        {
            collStudentCurriculumTotalUnitsEarneds = getStudentCurriculumTotalUnitsEarneds(new Criteria(10));
        }
        return collStudentCurriculumTotalUnitsEarneds;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum has previously
     * been saved, it will retrieve related StudentCurriculumTotalUnitsEarneds from storage.
     * If this Curriculum is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getStudentCurriculumTotalUnitsEarneds(Criteria criteria) throws TorqueException
    {
        if (collStudentCurriculumTotalUnitsEarneds == null)
        {
            if (isNew())
            {
               collStudentCurriculumTotalUnitsEarneds = new ArrayList();
            }
            else
            {
                      criteria.add(StudentCurriculumTotalUnitsEarnedPeer.CURRICULUMID, getCurriculumId() );
                      collStudentCurriculumTotalUnitsEarneds = StudentCurriculumTotalUnitsEarnedPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(StudentCurriculumTotalUnitsEarnedPeer.CURRICULUMID, getCurriculumId());
                      if (!lastStudentCurriculumTotalUnitsEarnedsCriteria.equals(criteria))
                {
                    collStudentCurriculumTotalUnitsEarneds = StudentCurriculumTotalUnitsEarnedPeer.doSelect(criteria);
                }
            }
        }
        lastStudentCurriculumTotalUnitsEarnedsCriteria = criteria;

        return collStudentCurriculumTotalUnitsEarneds;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getStudentCurriculumTotalUnitsEarneds(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getStudentCurriculumTotalUnitsEarneds(Connection con) throws TorqueException
    {
        if (collStudentCurriculumTotalUnitsEarneds == null)
        {
            collStudentCurriculumTotalUnitsEarneds = getStudentCurriculumTotalUnitsEarneds(new Criteria(10), con);
        }
        return collStudentCurriculumTotalUnitsEarneds;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum has previously
     * been saved, it will retrieve related StudentCurriculumTotalUnitsEarneds from storage.
     * If this Curriculum is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getStudentCurriculumTotalUnitsEarneds(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collStudentCurriculumTotalUnitsEarneds == null)
        {
            if (isNew())
            {
               collStudentCurriculumTotalUnitsEarneds = new ArrayList();
            }
            else
            {
                       criteria.add(StudentCurriculumTotalUnitsEarnedPeer.CURRICULUMID, getCurriculumId());
                       collStudentCurriculumTotalUnitsEarneds = StudentCurriculumTotalUnitsEarnedPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(StudentCurriculumTotalUnitsEarnedPeer.CURRICULUMID, getCurriculumId());
                       if (!lastStudentCurriculumTotalUnitsEarnedsCriteria.equals(criteria))
                 {
                     collStudentCurriculumTotalUnitsEarneds = StudentCurriculumTotalUnitsEarnedPeer.doSelect(criteria, con);
                 }
             }
         }
         lastStudentCurriculumTotalUnitsEarnedsCriteria = criteria;

         return collStudentCurriculumTotalUnitsEarneds;
     }

                        
              
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum is new, it will return
     * an empty collection; or if this Curriculum has previously
     * been saved, it will retrieve related StudentCurriculumTotalUnitsEarneds from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Curriculum.
     */
    protected List getStudentCurriculumTotalUnitsEarnedsJoinStudent(Criteria criteria)
        throws TorqueException
    {
        if (collStudentCurriculumTotalUnitsEarneds == null)
        {
            if (isNew())
            {
               collStudentCurriculumTotalUnitsEarneds = new ArrayList();
            }
            else
            {
                            criteria.add(StudentCurriculumTotalUnitsEarnedPeer.CURRICULUMID, getCurriculumId());
                            collStudentCurriculumTotalUnitsEarneds = StudentCurriculumTotalUnitsEarnedPeer.doSelectJoinStudent(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(StudentCurriculumTotalUnitsEarnedPeer.CURRICULUMID, getCurriculumId());
                        if (!lastStudentCurriculumTotalUnitsEarnedsCriteria.equals(criteria))
            {
                collStudentCurriculumTotalUnitsEarneds = StudentCurriculumTotalUnitsEarnedPeer.doSelectJoinStudent(criteria);
            }
        }
        lastStudentCurriculumTotalUnitsEarnedsCriteria = criteria;

        return collStudentCurriculumTotalUnitsEarneds;
    }
                  
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum is new, it will return
     * an empty collection; or if this Curriculum has previously
     * been saved, it will retrieve related StudentCurriculumTotalUnitsEarneds from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Curriculum.
     */
    protected List getStudentCurriculumTotalUnitsEarnedsJoinCurriculum(Criteria criteria)
        throws TorqueException
    {
        if (collStudentCurriculumTotalUnitsEarneds == null)
        {
            if (isNew())
            {
               collStudentCurriculumTotalUnitsEarneds = new ArrayList();
            }
            else
            {
                            criteria.add(StudentCurriculumTotalUnitsEarnedPeer.CURRICULUMID, getCurriculumId());
                            collStudentCurriculumTotalUnitsEarneds = StudentCurriculumTotalUnitsEarnedPeer.doSelectJoinCurriculum(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(StudentCurriculumTotalUnitsEarnedPeer.CURRICULUMID, getCurriculumId());
                        if (!lastStudentCurriculumTotalUnitsEarnedsCriteria.equals(criteria))
            {
                collStudentCurriculumTotalUnitsEarneds = StudentCurriculumTotalUnitsEarnedPeer.doSelectJoinCurriculum(criteria);
            }
        }
        lastStudentCurriculumTotalUnitsEarnedsCriteria = criteria;

        return collStudentCurriculumTotalUnitsEarneds;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collCurriculumClassifications
     */
    protected List collCurriculumClassifications;

    /**
     * Temporary storage of collCurriculumClassifications to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initCurriculumClassifications()
    {
        if (collCurriculumClassifications == null)
        {
            collCurriculumClassifications = new ArrayList();
        }
    }

    /**
     * Method called to associate a CurriculumClassification object to this object
     * through the CurriculumClassification foreign key attribute
     *
     * @param l CurriculumClassification
     * @throws TorqueException
     */
    public void addCurriculumClassification(CurriculumClassification l) throws TorqueException
    {
        getCurriculumClassifications().add(l);
        l.setCurriculum((Curriculum) this);
    }

    /**
     * The criteria used to select the current contents of collCurriculumClassifications
     */
    private Criteria lastCurriculumClassificationsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCurriculumClassifications(new Criteria())
     *
     * @throws TorqueException
     */
    public List getCurriculumClassifications() throws TorqueException
    {
        if (collCurriculumClassifications == null)
        {
            collCurriculumClassifications = getCurriculumClassifications(new Criteria(10));
        }
        return collCurriculumClassifications;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum has previously
     * been saved, it will retrieve related CurriculumClassifications from storage.
     * If this Curriculum is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getCurriculumClassifications(Criteria criteria) throws TorqueException
    {
        if (collCurriculumClassifications == null)
        {
            if (isNew())
            {
               collCurriculumClassifications = new ArrayList();
            }
            else
            {
                      criteria.add(CurriculumClassificationPeer.CURRICULUMID, getCurriculumId() );
                      collCurriculumClassifications = CurriculumClassificationPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(CurriculumClassificationPeer.CURRICULUMID, getCurriculumId());
                      if (!lastCurriculumClassificationsCriteria.equals(criteria))
                {
                    collCurriculumClassifications = CurriculumClassificationPeer.doSelect(criteria);
                }
            }
        }
        lastCurriculumClassificationsCriteria = criteria;

        return collCurriculumClassifications;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getCurriculumClassifications(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCurriculumClassifications(Connection con) throws TorqueException
    {
        if (collCurriculumClassifications == null)
        {
            collCurriculumClassifications = getCurriculumClassifications(new Criteria(10), con);
        }
        return collCurriculumClassifications;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum has previously
     * been saved, it will retrieve related CurriculumClassifications from storage.
     * If this Curriculum is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getCurriculumClassifications(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collCurriculumClassifications == null)
        {
            if (isNew())
            {
               collCurriculumClassifications = new ArrayList();
            }
            else
            {
                       criteria.add(CurriculumClassificationPeer.CURRICULUMID, getCurriculumId());
                       collCurriculumClassifications = CurriculumClassificationPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(CurriculumClassificationPeer.CURRICULUMID, getCurriculumId());
                       if (!lastCurriculumClassificationsCriteria.equals(criteria))
                 {
                     collCurriculumClassifications = CurriculumClassificationPeer.doSelect(criteria, con);
                 }
             }
         }
         lastCurriculumClassificationsCriteria = criteria;

         return collCurriculumClassifications;
     }

                  
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Curriculum is new, it will return
     * an empty collection; or if this Curriculum has previously
     * been saved, it will retrieve related CurriculumClassifications from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Curriculum.
     */
    protected List getCurriculumClassificationsJoinCurriculum(Criteria criteria)
        throws TorqueException
    {
        if (collCurriculumClassifications == null)
        {
            if (isNew())
            {
               collCurriculumClassifications = new ArrayList();
            }
            else
            {
                            criteria.add(CurriculumClassificationPeer.CURRICULUMID, getCurriculumId());
                            collCurriculumClassifications = CurriculumClassificationPeer.doSelectJoinCurriculum(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(CurriculumClassificationPeer.CURRICULUMID, getCurriculumId());
                        if (!lastCurriculumClassificationsCriteria.equals(criteria))
            {
                collCurriculumClassifications = CurriculumClassificationPeer.doSelectJoinCurriculum(criteria);
            }
        }
        lastCurriculumClassificationsCriteria = criteria;

        return collCurriculumClassifications;
    }
                            


          
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
              fieldNames.add("CurriculumId");
              fieldNames.add("CurriculumCode");
              fieldNames.add("CurriculumName");
              fieldNames.add("TotalUnits");
              fieldNames.add("AHCount");
              fieldNames.add("MSTCount");
              fieldNames.add("SSPCount");
              fieldNames.add("ElectiveCount");
              fieldNames.add("DegreeId");
              fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
          if (name.equals("CurriculumId"))
        {
                return new Integer(getCurriculumId());
            }
          if (name.equals("CurriculumCode"))
        {
                return getCurriculumCode();
            }
          if (name.equals("CurriculumName"))
        {
                return getCurriculumName();
            }
          if (name.equals("TotalUnits"))
        {
                return new Integer(getTotalUnits());
            }
          if (name.equals("AHCount"))
        {
                return new Integer(getAHCount());
            }
          if (name.equals("MSTCount"))
        {
                return new Integer(getMSTCount());
            }
          if (name.equals("SSPCount"))
        {
                return new Integer(getSSPCount());
            }
          if (name.equals("ElectiveCount"))
        {
                return new Integer(getElectiveCount());
            }
          if (name.equals("DegreeId"))
        {
                return new Integer(getDegreeId());
            }
          return null;
    }
    
    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
          if (name.equals(CurriculumPeer.CURRICULUMID))
        {
                return new Integer(getCurriculumId());
            }
          if (name.equals(CurriculumPeer.CURRICULUMCODE))
        {
                return getCurriculumCode();
            }
          if (name.equals(CurriculumPeer.CURRICULUMNAME))
        {
                return getCurriculumName();
            }
          if (name.equals(CurriculumPeer.TOTALUNITS))
        {
                return new Integer(getTotalUnits());
            }
          if (name.equals(CurriculumPeer.NUMBERAH))
        {
                return new Integer(getAHCount());
            }
          if (name.equals(CurriculumPeer.NUMBERMST))
        {
                return new Integer(getMSTCount());
            }
          if (name.equals(CurriculumPeer.NUMBERSSP))
        {
                return new Integer(getSSPCount());
            }
          if (name.equals(CurriculumPeer.NUMBERELECTIVE))
        {
                return new Integer(getElectiveCount());
            }
          if (name.equals(CurriculumPeer.DEGREEID))
        {
                return new Integer(getDegreeId());
            }
          return null;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
            if (pos == 0)
        {
                return new Integer(getCurriculumId());
            }
              if (pos == 1)
        {
                return getCurriculumCode();
            }
              if (pos == 2)
        {
                return getCurriculumName();
            }
              if (pos == 3)
        {
                return new Integer(getTotalUnits());
            }
              if (pos == 4)
        {
                return new Integer(getAHCount());
            }
              if (pos == 5)
        {
                return new Integer(getMSTCount());
            }
              if (pos == 6)
        {
                return new Integer(getSSPCount());
            }
              if (pos == 7)
        {
                return new Integer(getElectiveCount());
            }
              if (pos == 8)
        {
                return new Integer(getDegreeId());
            }
              return null;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
          save(CurriculumPeer.getMapBuilder()
                .getDatabaseMap().getName());
      }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
       * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
       *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
          try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
      }

      /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
      /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
          if (!alreadyInSave)
        {
            alreadyInSave = true;


  
            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    CurriculumPeer.doInsert((Curriculum) this, con);
                    setNew(false);
                }
                else
                {
                    CurriculumPeer.doUpdate((Curriculum) this, con);
                }
            }

                                      
                
            if (collCurriculumCourses != null)
            {
                for (int i = 0; i < collCurriculumCourses.size(); i++)
                {
                    ((CurriculumCourse) collCurriculumCourses.get(i)).save(con);
                }
            }
                                          
                
            if (collStudents != null)
            {
                for (int i = 0; i < collStudents.size(); i++)
                {
                    ((Student) collStudents.get(i)).save(con);
                }
            }
                                          
                
            if (collStudentCurriculumTotalUnitsEarneds != null)
            {
                for (int i = 0; i < collStudentCurriculumTotalUnitsEarneds.size(); i++)
                {
                    ((StudentCurriculumTotalUnitsEarned) collStudentCurriculumTotalUnitsEarneds.get(i)).save(con);
                }
            }
                                          
                
            if (collCurriculumClassifications != null)
            {
                for (int i = 0; i < collCurriculumClassifications.size(); i++)
                {
                    ((CurriculumClassification) collCurriculumClassifications.get(i)).save(con);
                }
            }
                          alreadyInSave = false;
        }
      }


                          
      /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param  curriculumId ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
            setCurriculumId(((NumberKey) key).intValue());
        }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
            setCurriculumId(Integer.parseInt(key));
        }

  
    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
          return SimpleKey.keyFor(getCurriculumId());
      }

 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
       * It then fills all the association collections and sets the
     * related objects to isNew=true.
       */
      public Curriculum copy() throws TorqueException
    {
        return copyInto(new Curriculum());
    }
  
    protected Curriculum copyInto(Curriculum copyObj) throws TorqueException
    {
          copyObj.setCurriculumId(curriculumId);
          copyObj.setCurriculumCode(curriculumCode);
          copyObj.setCurriculumName(curriculumName);
          copyObj.setTotalUnits(totalUnits);
          copyObj.setAHCount(aHCount);
          copyObj.setMSTCount(mSTCount);
          copyObj.setSSPCount(sSPCount);
          copyObj.setElectiveCount(electiveCount);
          copyObj.setDegreeId(degreeId);
  
                    copyObj.setCurriculumId(0);
                                                            
                                      
                
        List v = getCurriculumCourses();
        for (int i = 0; i < v.size(); i++)
        {
            CurriculumCourse obj = (CurriculumCourse) v.get(i);
            copyObj.addCurriculumCourse(obj.copy());
        }
                                                  
                
        v = getStudents();
        for (int i = 0; i < v.size(); i++)
        {
            Student obj = (Student) v.get(i);
            copyObj.addStudent(obj.copy());
        }
                                                  
                
        v = getStudentCurriculumTotalUnitsEarneds();
        for (int i = 0; i < v.size(); i++)
        {
            StudentCurriculumTotalUnitsEarned obj = (StudentCurriculumTotalUnitsEarned) v.get(i);
            copyObj.addStudentCurriculumTotalUnitsEarned(obj.copy());
        }
                                                  
                
        v = getCurriculumClassifications();
        for (int i = 0; i < v.size(); i++)
        {
            CurriculumClassification obj = (CurriculumClassification) v.get(i);
            copyObj.addCurriculumClassification(obj.copy());
        }
                    
        return copyObj;
    }

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public CurriculumPeer getPeer()
    {
        return peer;
    }

    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Curriculum:\n");
        str.append("CurriculumId = ")
           .append(getCurriculumId())
           .append("\n");
        str.append("CurriculumCode = ")
           .append(getCurriculumCode())
           .append("\n");
        str.append("CurriculumName = ")
           .append(getCurriculumName())
           .append("\n");
        str.append("TotalUnits = ")
           .append(getTotalUnits())
           .append("\n");
        str.append("AHCount = ")
           .append(getAHCount())
           .append("\n");
        str.append("MSTCount = ")
           .append(getMSTCount())
           .append("\n");
        str.append("SSPCount = ")
           .append(getSSPCount())
           .append("\n");
        str.append("ElectiveCount = ")
           .append(getElectiveCount())
           .append("\n");
        str.append("DegreeId = ")
           .append(getDegreeId())
           .append("\n");
        return(str.toString());
    }
}
